<%@page import="java.util.TimeZone"%>
<%@page import="java.util.List"%>
<%@page import="com.test.google.app.util.DateUtil"%>
<%@page import="com.test.google.app.domain.SyncFileTask"%>
<%@page import="com.google.appengine.api.datastore.Entity"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>后台管理 - Xite</title>
    <link href="/css/bootstrap.xuper.css" rel="stylesheet" type="text/css"/>
    <link href="/css/default.css" rel="stylesheet" type="text/css"/>
    <script type="text/javascript" src="/js/jquery-1.8.2.min.js"></script>
    <!--[if IE 6]>
    <script language="javascript" type="text/javascript" src="/js/DD_belatedPNG_0.0.8a-min.js"></script>
    <script type="text/javascript">
        $(function(){
            DD_belatedPNG.fix('.png-fix');
        });
    </script>
    <![endif]-->
<script type="text/javascript" >
function add(form) {
	if (form.targetUrl.value == "") {
		alert("目标地址不能为空！");
		form.targetUrl.focus();
		return;
	}
	if (form.localPath.value == "") {
		alert("本地文件路径不能为空！");
		form.localPath.focus();
		return;
	}
	form.submit();
}
</script>
</head>
<body>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
    <tr>
        <td height="100" valign="bottom">
            <table width="1000" border="0" align="center" cellpadding="0" cellspacing="0">
                <tr>
                    <td class="" width="1064" height="100" valign="bottom">
                        <!--<div class="png-fix"></div>-->
                    </td>
                </tr>
            </table>
        </td>
    </tr>
    <tr>
        <td height="117" valign="top">
            <table width="900" height="100%" border="0" align="center" cellpadding="0" cellspacing="0"
                   bgcolor="#FFFFFF">
                <tr>
                    <td width="8" height="8" align="left" valign="top" background="/img/left-middle.gif"><img
                            src="/img/left-top.gif" width="8" height="8"/></td>
                    <td width="984" height="8" valign="top"><img src="/img/top-middle.gif" width="984" height="8"/></td>
                    <td width="10" align="right" valign="top"><img src="/img/right-top.gif" width="8" height="8"/></td>
                </tr>
                <tr>
                    <td width="8" height="423" valign="top" background="/img/left-middle.gif"><img
                            src="/img/left-middle.gif" width="8" height="2"/></td>
                    <td valign="top">
                        <table id="main-container" width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
                            <tr>
                                <td width="195" height="389" valign="top">
									<jsp:include page="../sys/menu.jsp" />
                                </td>
                                <td width="19" valign="top" background="/img/splitmiddle.gif"><img
                                        src="/img/splitmiddle.gif" width="10" height="10"/></td>
                                <td width="770" valign="top">
                                    <div id="container">
                                        <div id="location">你现在的位置: <strong>同步文件管理</strong></div>
<div id="datas">
	<%if (request.getAttribute("msg") != null) {%>
		${msg}
	<%} %>
	<div>
    <table width="97%" border="0" align="left" cellpadding="0" cellspacing="0" class="gridtable">
        <tr>
            <th>#</th>
            <th>目标地址</th>
            <th>本地文件名</th>
            <th>同步周期</th>
            <th>上次同步</th>
            <th>操作</th>
        </tr>
        <%
        List<SyncFileTask> list = (List<SyncFileTask>)request.getAttribute("list");
        for (int i=0; i<list.size(); i++) {
        %>
        <tr>
            <td><%=i + 1%></td>
            <td><%=list.get(i).getTargetUrl()%></td>
            <td><%=list.get(i).getLocalPath()%></td>
            <td><%=list.get(i).getSyncCycle()%> 分钟</td>
            <td><%String dateStr = list.get(i).getLastSyncTime();%>
            	<%if  (dateStr != null && !dateStr.equals("")) { %>
            	<%=(System.currentTimeMillis() - DateUtil.toDateTime(dateStr).getTime())/1000%> 秒前
            	<%} %>
            </td>
            <td><a style="color: red;" href="delete.do?id=<%=list.get(i).getKey().getId() %>"
                   onclick="return confirm('您确定要此任务吗?')">[删除]</a></td>
        </tr>
        <%} %>
    </table>
    </div>
    <h3>同步数量限制<%=list.size()%>/5个</h3>
    <br /><br /><br /><br /><br /><br /><br /><br /><br /><br />
    <div>
    <form class="form-horizontal zhcn" action="add.do" method="post">
        <input class="input-large" name="action" value="add" type="hidden"/>
        <h4 class="page-header zhcn">添加同步文件</h4>
        <div class="control-group">
            <div class="control-group">
                <label class="control-label">目标地址: </label>
                <div class="controls">
                    <input class="input-large" name="targetUrl" type="text" id="txt_target_url"/>
                    <span style="color: red;"> *</span>
                    <span class="help-inline">如: http://sina.com.cn</span>
                </div>
            </div>
            <div class="control-group">
                <label class="control-label">本地文件路径: </label>
                <div class="controls">
                    <input class="input-large" name="localPath" type="text" id="txt_local_path"/>
                    <span style="color: red;"> *</span>
                    <span class="help-inline">如: test.html</span>
                </div>
            </div>
            <div class="control-group">
                <label class="control-label">同步周期: </label>
                <div class="controls">
                    <select class="" name="syncCycle" id="sel_period">
                        <option value="2">2分钟</option>
                        <option value="5">5分钟</option>
                        <option value="10">10分钟</option>
                        <option value="30">30分钟</option>
                        <option value="60">60分钟</option>
                    </select>
                </div>
            </div>
            <div class="form-actions">
                <button class="btn btn-primary" id="submit_btn" type="button" onclick="add(this.form)">添加文件</button>
            </div>
        </div>
    </form>
    </div>
</div>


                                    </div>
                                </td>
                            </tr>
                        </table>
                    </td>
                    <td width="8" valign="top" background="/img/right-middle.gif"><img
                            src="/img/right-middle.gif"
                            width="8" height="2"/></td>
                </tr>
                <tr>
                    <td height="8" align="left" valign="top" background="/img/left-middle.gif"><img
                            src="/img/left-bottom.gif" width="8" height="8"/></td>
                    <td height="8" valign="top"><img src="/img/bottom-middle.gif" width="984" height="8"/></td>
                    <td width="10" height="8" align="right" valign="top" background="/img/right-middle.gif"><img
                            src="/img/right-bottom.gif" width="8" height="8"/></td>
                </tr>
            </table>
        </td>
    </tr>
</table>
<table width="100%" height="154" border="0" cellpadding="0" cellspacing="0">
    <tr>
        <td>
            <table width="800" height="154" border="0" align="center" cellpadding="0" cellspacing="0">
                <tr>
                    <td width="1000" valign="top">
                        <table width="800" border="0" cellspacing="0" cellpadding="0">
                            <tr>
                                <td width="14" background="/img/drop-middle.gif"><img src="/img/drop-left.gif"
                                                                                          width="6" height="73"/></td>
                                <td width="979" valign="bottom" background="/img/drop-middle.gif">
                                    <div align="center">
                                        <div align="center">
                                            <div align="center" style="color:#006699;">
                                                Copyright &copy; 2013 Xite
                                            </div>
                                        </div>
                                    </div>
                                </td>
                                <td width="10" valign="top" background="/img/drop-middle.gif">
                                    <div align="right"><img src="/img/drop-right.gif" width="6" height="73"/></div>
                                </td>
                            </tr>
                        </table>
                    </td>
                </tr>
            </table>
        </td>
    </tr>
</table>
</body>
</html>
